# Copyright (c) 2017 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.flow.topic_map_util import (expand_worker,
                                      expand_group_worker,
                                      expand_list,
                                      topic_id_to_multicast_addr,
                                      check_topic_id_to_string_map)

topic_id_to_string_map = check_topic_id_to_string_map(
    expand_list([
        # 237.15.0.1        0x0000ED0F0001xxxx: bitmex
        (0x0000ED0F00011000, 'bitmex_ws_topic_event'),
        expand_group_worker(0x0000ED0F00011100, 'bitmex_ws_orderBookL2_', num_group=6,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00011200, 'bitmex_ws_orderBook10_', num_group=6,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00011300, 'bitmex_ws_trade_', num_group=6, num_worker=8),
        expand_worker(0x0000ED0F00011400, 'bitmex_ws_instrument_', num_worker=8),
        expand_worker(0x0000ED0F00011500, 'bitmex_ws_liquidation_', num_worker=8),
        expand_worker(0x0000ED0F00019000, 'bitmex_ws_private_', num_worker=8),

        # 237.15.0.2       0x0000ED0F0002xxxx: bitfinex
        (0x0000ED0F00021000, 'bitfinex_v2_ws_topic_event'),
        expand_group_worker(0x0000ED0F00021100, 'bitfinex_v2_ws_book_', num_group=13, num_worker=4),
        expand_group_worker(0x0000ED0F00021200,
                            'bitfinex_v2_ws_rawBook_',
                            num_group=13,
                            num_worker=4),
        expand_group_worker(0x0000ED0F00021300,
                            'bitfinex_v2_ws_trades_',
                            num_group=13,
                            num_worker=4),
        expand_group_worker(0x0000ED0F00021400, 'bitfinex_v2_ws_etc_', num_group=13, num_worker=4),
        expand_worker(0x0000ED0F00041500, 'bitfinex_v2_ws_private_', num_worker=4),

        # 237.15.0.3        0x0000ED0F0003xxxx: gdax
        (0x0000ED0F00031000, 'gdax_ws_topic_event'),
        expand_group_worker(0x0000ED0F00031100, 'gdax_ws_level2_', num_group=6, num_worker=8),
        expand_group_worker(0x0000ED0F00031200, 'gdax_ws_full_', num_group=6, num_worker=8),
        expand_worker(0x0000ED0F00032000, 'gdax_rest_private_', num_worker=4),

        # 237.15.0.4        0x0000ED0F0004xxxx: binance
        (0x0000ED0F00041000, 'binance_ws_topic_event'),
        expand_group_worker(0x0000ED0F00041100, 'binance_ws_depth_', num_group=16, num_worker=8),
        expand_group_worker(0x0000ED0F00041200, 'binance_ws_depth20_', num_group=16, num_worker=8),
        expand_group_worker(0x0000ED0F00041300, 'binance_ws_trade_', num_group=16, num_worker=8),
        expand_group_worker(0x0000ED0F00041800,
                            'binance_ws_book_ticker_',
                            num_group=16,
                            num_worker=8),
        expand_worker(0x0000ED0F00041400, 'binance_ws_private_', num_worker=8),
        expand_worker(0x0000ED0F00042000, 'binance_rest_depth_', num_worker=8),
        expand_worker(0x0000ED0F00042100, 'binance_rest_private_', num_worker=8),
        expand_group_worker(0x0000ED0F00041600, 'binance_ws_depth_1s_', num_group=16, num_worker=8),
        expand_group_worker(0x0000ED0F00041700,
                            'binance_ws_depth20_1s_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00043000,
                            'binance_ws_futures_depth_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00043100,
                            'binance_ws_futures_trade_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00043200,
                            'binance_ws_futures_mark_price_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00043300,
                            'binance_ws_futures_ticker_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F00043500,
                            'binance_ws_futures_book_ticker_',
                            num_group=16,
                            num_worker=8),
        expand_worker(0x0000ED0F00043400, 'binance_rest_futures_depth_', num_worker=8),

        # 237.15.0.5        0x0000ED0F0005xxxx: bittrex
        (0x0000ED0F00051000, 'bittrex_ws_topic_event'),
        expand_worker(0x0000ED0F00051100, 'bittrex_rest_private_', num_worker=4),

        # 237.15.0.6        0x0000ED0F0006xxxx: gemini

        # 237.15.0.7        0x0000ED0F0007xxxx: coinone
        (0x0000ED0F00071000, 'coinone_ws_topic_event'),
        expand_group_worker(0x0000ED0F00071100, 'coinone_ws_depth_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00071200, 'coinone_ws_trade_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00071300, 'coinone_ws_ticker_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00071400, 'coinone_rest_depth_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00071500, 'coinone_rest_trade_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00071600, 'coinone_rest_ticker_', num_group=16, num_worker=2),
        expand_worker(0x0000ED0F00071700, 'coinone_rest_private_', num_worker=4),

        # 237.15.0.8        0x0000ED0F0008xxxx: bithumb
        (0x0000ED0F00081000, 'bithumb_ws_topic_event'),
        expand_group_worker(0x0000ED0F00081100, 'bithumb_ws_depth_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00081200, 'bithumb_ws_trade_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00081400, 'bithumb_ws_quote_', num_group=16, num_worker=2),
        expand_group_worker(0x0000ED0F00081300, 'bithumb_ws_ticker_', num_group=16, num_worker=2),
        expand_worker(0x0000ED0F00082000, 'bithumb_rest_private_', num_worker=4),

        # 237.15.0.9        0x0000ED0F0009xxxx: poloniex

        # 237.15.0.10       0x0000ED0F000Axxxx: huobi
        (0x0000ED0F000A1000, 'huobi_ws_topic_event'),
        expand_group_worker(0x0000ED0F000A1100, 'huobi_ws_depth_', num_group=16, num_worker=4),
        expand_group_worker(0x0000ED0F000A1600, 'huobi_ws_delta_depth_', num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000A1200, 'huobi_ws_trade_', num_group=16, num_worker=4),
        expand_group_worker(0x0000ED0F000A1300,
                            'huobi_ws_futures_depth_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000A1700,
                            'huobi_ws_futures_delta_depth_',
                            num_group=16,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000A1400,
                            'huobi_ws_futures_trade_',
                            num_group=16,
                            num_worker=8),
        (0x0000ED0F000A1500, 'huobi_ws_futures_topic_event'),
        expand_worker(0x0000ED0F000A2100, 'huobi_rest_private_', num_worker=4),
        expand_worker(0x0000ED0F000A2200, 'huobi_futures_rest_private_', num_worker=4),

        # 237.15.0.11       0x0000ED0F000Bxxxx: okex
        (0x0000ED0F000B1000, 'okex_ws_topic_event'),
        expand_group_worker(0x0000ED0F000B1100,
                            'okex_ws_spot_depth_fullbook_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B1200,
                            'okex_ws_spot_depth_diff_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B1300,
                            'okex_ws_spot_depth_20_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B1400, 'okex_ws_spot_deals_', num_group=16, num_worker=4),
        expand_worker(0x0000ED0F000B1500, 'okex_spot_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F000B2000,
                            'okex_ws_futureusd_depth_fullbook_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B2100,
                            'okex_ws_futureusd_depth_diff_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B2200,
                            'okex_ws_futureusd_depth_20_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B2300,
                            'okex_ws_futureusd_trade_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B2400,
                            'okex_ws_futureusd_index_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B2500,
                            'okex_ws_futureusd_ticker_',
                            num_group=8,
                            num_worker=8),
        expand_worker(0x0000ED0F000B2600, 'okex_futureusd_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F000B3000,
                            'okex_ws_swap_depth_fullbook_',
                            num_group=8,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B3100,
                            'okex_ws_swap_depth_diff_',
                            num_group=8,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B3200, 'okex_ws_swap_trade_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F000B3300, 'okex_ws_swap_ticker_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F000B3500,
                            'okex_ws_swap_price_range_',
                            num_group=8,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B3600,
                            'okex_ws_swap_funding_rate_',
                            num_group=8,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B3700,
                            'okex_ws_swap_mark_price_',
                            num_group=8,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B3800,
                            'okex_rest_swap_open_interest_',
                            num_group=8,
                            num_worker=8),
        expand_worker(0x0000ED0F000B3400, 'okex_swap_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F000B4000,
                            'okex_ws_futures_v3_depth_fullbook_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4100,
                            'okex_ws_futures_v3_depth_diff_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4200,
                            'okex_ws_futures_v3_trade_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4300,
                            'okex_ws_futures_v3_ticker_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4400,
                            'okex_ws_futures_v3_price_range_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4500,
                            'okex_ws_futures_v3_mark_price_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4600,
                            'okex_rest_futures_v3_open_interest_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4700,
                            'okex_ws_futures_v3_realtime_depth_fullbook_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B4800,
                            'okex_ws_futures_v3_realtime_depth_diff_',
                            num_group=8,
                            num_worker=8),
        expand_group_worker(0x0000ED0F000B5000,
                            'okex_ws_spot_v3_depth_fullbook_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B5100,
                            'okex_ws_spot_v3_depth_diff_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B5200,
                            'okex_ws_spot_v3_trade_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B5300,
                            'okex_ws_spot_v3_ticker_',
                            num_group=16,
                            num_worker=4),
        # coin2
        expand_group_worker(0x0000ED0F000B5400, 'okex_feed_v3_', num_group=16, num_worker=4),
        expand_group_worker(0x0000ED0F000B5500, 'okex_futures_feed_v3_', num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000B5600, 'spot_okex_v3_', num_group=16, num_worker=4),
        expand_group_worker(0x0000ED0F000B5700, 'futures_okex_v3_', num_group=16, num_worker=4),

        # 237.15.0.12       0x0000ED0F000Cxxxx: upbit
        (0x0000ED0F000C1000, 'upbit_ws_topic_event'),
        expand_group_worker(0x0000ED0F000C1100, 'upbit_ws_depth_', num_group=3, num_worker=4),
        expand_group_worker(0x0000ED0F000C1200, 'upbit_ws_trade_', num_group=3, num_worker=4),
        expand_worker(0x0000ED0F000C2000, 'upbit_rest_private_', num_worker=4),

        # 237.15.0.13       0x0000ED0F000Dxxxx: bitflyer
        (0x0000ED0F000D1000, 'bitflyer_pubnub_topic_event'),
        expand_group_worker(0x0000ED0F000D1100,
                            'bitflyer_pubnub_board_snapshot_',
                            num_group=2,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000D1200,
                            'bitflyer_pubnub_board_diff_',
                            num_group=2,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000D1300,
                            'bitflyer_pubnub_ticker_',
                            num_group=2,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000D1400,
                            'bitflyer_pubnub_executions_',
                            num_group=2,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000D1500,
                            'bitflyer_ws_ticker_board_',
                            num_group=6,
                            num_worker=8),
        expand_worker(0x0000ED0F000D2000, 'bitflyer_rest_private_', num_worker=4),

        # 237.15.0.14       0x0000ED0F000Exxxx: kraken
        (0x0000ED0F000E1000, 'kraken_rest_topic_event'),
        expand_group_worker(0x0000ED0F000E1100, 'kraken_rest_depth_', num_group=2, num_worker=4),
        expand_group_worker(0x0000ED0F000E1200, 'kraken_rest_trade_', num_group=2, num_worker=4),
        expand_worker(0x0000ED0F000E1300, 'kraken_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F000E1400, 'kraken_ws_depth_', num_group=2, num_worker=4),
        expand_group_worker(0x0000ED0F000E1500, 'kraken_ws_trade_', num_group=2, num_worker=4),
        expand_group_worker(0x0000ED0F000E1600,
                            'kraken_futures_ws_depth_',
                            num_group=1,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000E1700,
                            'kraken_futures_ws_trade_',
                            num_group=1,
                            num_worker=4),
        expand_group_worker(0x0000ED0F000E1800,
                            'kraken_futures_ws_ticker_',
                            num_group=1,
                            num_worker=4),
        expand_worker(0x0000ED0F000E1900, 'kraken_futures_rest_private_', num_worker=4),
        (0x0000ED0F000E2000, 'kraken_futures_ws_topic_event'),

        # 237.15.0.15       0x0000ED0F000Fxxxx: fcoin
        (0x0000ED0F000F1000, 'fcoin_ws_topic_event'),
        expand_group_worker(0x0000ED0F000F1100, 'fcoin_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F000F1200, 'fcoin_ws_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F000F1300, 'fcoin_rest_private_', num_worker=4),

        # 237.15.0.16       0x0000ED0F0010xxxx: quoinex
        (0x0000ED0F00101000, 'quoinex_ws_topic_event'),
        expand_group_worker(0x0000ED0F00101100, 'quoinex_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00101200, 'quoinex_ws_trade_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00101400,
                            'quoinex_ws_single_channel_depth_',
                            num_group=16,
                            num_worker=4),
        expand_group_worker(0x0000ED0F00101500,
                            'quoinex_ws_single_channel_trade_',
                            num_group=16,
                            num_worker=4),
        expand_worker(0x0000ED0F00101300, 'quoinex_rest_private_', num_worker=4),

        # 237.15.0.17       0x0000ED0F0011xxxx: hitbtc
        (0x0000ED0F00111000, 'hitbtc_ws_topic_event'),
        expand_group_worker(0x0000ED0F00111100, 'hitbtc_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00111200, 'hitbtc_ws_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F00111300, 'hitbtc_ws_private_', num_worker=4),

        # 237.15.0.18       0x0000ED0F0012xxxx: bitstamp
        (0x0000ED0F00121000, 'bitstamp_ws_topic_event'),
        expand_group_worker(0x0000ED0F00121100, 'bitstamp_ws_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00121200, 'bitstamp_ws_trade_', num_group=8, num_worker=4),
        expand_worker(0x0000ED0F00121300, 'bitstamp_ws_private_', num_worker=4),
        expand_worker(0x0000ED0F00121400, 'bitstamp_rest_private_', num_worker=4),

        # 237.15.0.19       0x0000ED0F0013xxxx: korbit
        (0x0000ED0F00131000, 'korbit_ws_topic_event'),
        expand_group_worker(0x0000ED0F00131100, 'korbit_ws_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00131200, 'korbit_ws_trade_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00131300, 'korbit_rest_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00131400, 'korbit_rest_trade_', num_group=8, num_worker=4),
        expand_worker(0x0000ED0F00131500, 'korbit_rest_private_', num_worker=4),

        # 237.15.0.20       0x0000ED0F0014xxxx: Deribit
        (0x0000ED0F00141000, 'deribit_ws_topic_event'),
        expand_group_worker(0x0000ED0F00141100, 'deribit_ws_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00141200, 'deribit_ws_trade_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00141300, 'deribit_ws_ticker_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00141400,
                            'deribit_ws_interest_rate_',
                            num_group=8,
                            num_worker=4),
        expand_worker(0x0000ED0F00141500, 'deribit_futures_ws_private_', num_worker=4),
        expand_worker(0x0000ED0F00141600, 'deribit_futures_rest_private_', num_worker=4),

        # 237.15.0.21       0x0000ED0F0015xxxx: Gopax
        (0x0000ED0F00151000, 'gopax_ws_topic_event'),
        expand_group_worker(0x0000ED0F00151100, 'gopax_ws_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00151200, 'gopax_ws_trade_', num_group=8, num_worker=4),
        expand_worker(0x0000ED0F00151300, 'gopax_rest_private_', num_worker=4),

        # 237.15.0.22       0x0000ED0F0016xxxx: Bybit
        (0x0000ED0F00161000, 'bybit_ws_topic_event'),
        expand_group_worker(0x0000ED0F00161100, 'bybit_ws_depth_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00161200, 'bybit_ws_trade_', num_group=8, num_worker=4),
        expand_group_worker(0x0000ED0F00161300, 'bybit_ws_instrument_', num_group=8, num_worker=4),

        # 237.15.0.23       0x0000ED0F0017xxxx: bequant
        (0x0000ED0F00171000, 'bequant_ws_topic_event'),
        expand_group_worker(0x0000ED0F00171100, 'bequant_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00171200, 'bequant_ws_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F00171300, 'bequant_ws_private_', num_worker=4),

        # 237.15.0.24       0x0000ED0F0018xxxx: uniswapv3
        (0x0000ED0F00181000, 'uniswapv3_rest_topic_event'),
        expand_group_worker(0x0000ED0F00181100, 'uniswapv3_rest_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00181200, 'uniswapv3_rest_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F00181300, 'uniswap_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F00181400, 'uniswapv3_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00181500, 'uniswapv3_ws_trade_', num_group=1, num_worker=4),

        # 237.15.0.25       0x0000ED0F0019xxxx: pancakeswapv2
        (0x0000ED0F00191000, 'pancakeswapv2_rest_topic_event'),
        expand_group_worker(0x0000ED0F00191100, 'pancakeswapv2_rest_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00191200, 'pancakeswapv2_rest_trade_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00191300, 'pancakeswapv2_rest_reserve_', num_group=1, num_worker=4),

        # 237.15.0.26       0x0000ED0F0020xxxx: uniswapv2
        (0x0000ED0F00201000, 'uniswapv2_rest_topic_event'),
        expand_group_worker(0x0000ED0F00201100, 'uniswapv2_rest_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00201200, 'uniswapv2_rest_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F00201300, 'uniswapv2_rest_private_', num_worker=4),

        # 237.15.0.27       0x0000ED0F0021xxxx: uniswapv3-arbitrum
        (0x0000ED0F00211000, 'uniswapv3-arbitrum_rest_topic_event'),
        expand_group_worker(0x0000ED0F00211100, 'uniswapv3-arbitrum_rest_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00211200, 'uniswapv3-arbitrum_rest_trade_', num_group=1, num_worker=4),
        expand_worker(0x0000ED0F00211300, 'uniswapv3-arbitrum_rest_private_', num_worker=4),
        expand_group_worker(0x0000ED0F00211400, 'uniswapv3-arbitrum_ws_depth_', num_group=1, num_worker=4),
        expand_group_worker(0x0000ED0F00211500, 'uniswapv3-arbitrum_ws_trade_', num_group=1, num_worker=4),

        # 237.15.1.1
        (0x0000ED0F01011000, 'feed_checker_dump'),
    ]),
    check_topic_id_multicastable=True)

if __name__ == '__main__':
  for topic_id, topic_string in sorted(topic_id_to_string_map):
    multicast_addr = topic_id_to_multicast_addr(topic_id)
    print('0x%016X %-23s  %s' % (topic_id, '(%s)' % multicast_addr, topic_string))
